Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix log files not working in daemon mode, update some dependencies and silence poll interrupted error #361

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

MemoryLeak55
Copy link

I added the ability to the cli to set pid files, useful for systemd units. I added the ability to set a working dir, and updated daemonize and tracing to the latest versions. Logging to files now work in daemon mode, as well as no complaints from epoll about being interrupted

.open(log)
.unwrap_or_else(move |_| panic!("Could not create log file {}", &log));

let (non_blocking, _guard) = tracing_appender::non_blocking(log_file);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The _guard and thus log file will be dropped at the end of this branch. The _guard must be held at the top level in order for the log to keep working, i.e.

fn main() {
    ...
    let _guard;
    ...

                let (non_blocking, guard) = tracing_appender::non_blocking(log_file);
                _guard = guard;

    ...

this is basically the approach in the main branch

let _guard;
if background {
let log = matches.value_of("log").unwrap();
let log_file =
File::create(log).unwrap_or_else(|_| panic!("Could not create log file {}", log));
let (non_blocking, guard) = tracing_appender::non_blocking(log_file);
_guard = guard;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants